//
//  CouponGetListViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/9/29.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "CouponListGingViewController.h"


#import "BusinessCouponDetailViewController.h"

#import "HAODEsingleton.h"
#import "UIViewExt.h"
#import "HttpRequest.h"
#import "JSONKit.h"
#import "addhuiyuanViewController.h"
#import "CouponListUITableViewCell.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"
#import "UIButton+WebCache.h"
#import "huiyuanDetailsViewController.h"
#import "GetProductListViewController.h"
#import "TheLoginViewController.h"
#import "shouyingViewController.h"
#import "UMSocial.h"
@interface CouponListGingViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UISearchBarDelegate,UMSocialUIDelegate>
@property (strong, nonatomic) NSString *areaValue;
@property (strong, nonatomic) NSString*cityValue;

@property(nonatomic,strong)   NSString*shuoming;
@property(nonatomic,strong)   NSString*shareUrl;
@end

@implementation CouponListGingViewController

{
    UIScrollView*fengxiangScroll;
    UISearchBar *search;
    HAODEsingleton* commdity;
    MJRefreshHeaderView* _header;
    MJRefreshFooterView* _footer;
    NSMutableArray*couponId;
    NSMutableArray*title;
    NSMutableArray*price;
    NSMutableArray*qty;
    NSMutableArray*beginDate;
    NSMutableArray*endDate;
    NSMutableArray*imageUrl;
    UIView*fengxiangview;
    UIButton* quxiao;
    NSMutableArray*imageUrlFull;
     NSMutableArray*useLimitAmt;
    NSString *result;
    int pageNumber;
    MBProgressHUD *progressHud;
    
}
@synthesize alt = alt;

-(void)BackAction:(UIButton *)sender{
    
    [self.navigationController popViewControllerAnimated:YES];
    
    
    
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [[self rdv_tabBarController] setTabBarHidden:YES];
    
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    
    self.title=@"优惠券";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor blackColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    self.navigationController.navigationBarHidden = NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
    
//    if (isPad == UIUserInterfaceIdiomPad) {
//        
//    
//    
//    
//    }
    

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        NSLog(@"ipad");
    }
    else
    {
        NSLog(@"iphone or ipod");
    }
    
    

    
}


- (void)viewDidLoad
{
    
    [super viewDidLoad];
    
    [self addFooter];
    _table.delegate=self;
    _table.dataSource=self;
    [self.view addSubview:_table];
    _table.separatorStyle=UITableViewCellSeparatorStyleNone;
    commdity=[HAODEsingleton shared];
      [self add];
    
}

-(void)addProduct:(UIButton*)sender{
    
    GetProductListViewController *detailViewController = [[GetProductListViewController alloc] init];
    [self.navigationController pushViewController:detailViewController animated:YES];
    
    
}


-(void)add{
    
    
    
    self.sat=nil;
    
    
    pageNumber = 1;
    
    
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue: @"G" forKey:@"dataType"];
    [param setValue: @"20" forKey:@"pageSize"];
    [param setValue: @"1" forKey:@"pageIndex"];
    
    NSLog(@"====%@",param);
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
    
    
    [HttpRequest requestData:@"Business/Coupon/getList" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                NSString*TotalCount=[severDataDict.dataDict objectForKey:@"TotalCount"];
                
                if (TotalCount.intValue==0) {
                    
                    UILabel*noLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,ScreenHeight/2-50, ScreenWidth, 17)];
                    noLabel.text=@"无数据";
                    noLabel.textColor=[UIColor blackColor];
                    noLabel.textAlignment=NSTextAlignmentCenter;
                    
                    [self.view addSubview:noLabel];

                    
                }else{
                    
                    
                    imageUrlFull= [[NSMutableArray alloc] init];
                    imageUrl= [[NSMutableArray alloc] init];
                    endDate= [[NSMutableArray alloc] init];
                    beginDate= [[NSMutableArray alloc] init];
                    qty= [[NSMutableArray alloc] init];
                    price= [[NSMutableArray alloc] init];
                    title= [[NSMutableArray alloc] init];
                    couponId = [[NSMutableArray alloc] init];
                    useLimitAmt= [[NSMutableArray alloc] init];

                    
                    NSMutableArray* arrr=[[NSMutableArray alloc]init];
                    arrr=[severDataDict.dataDict objectForKey:@"DataLine"];
                    for (NSDictionary* dicc in arrr )
                    {
                        [title addObject:[dicc valueForKey:@"title"]];
                        [price addObject:[dicc valueForKey:@"price"]];
                        [qty addObject:[dicc valueForKey:@"qty"]];
                        [couponId addObject:[dicc valueForKey:@"couponId"]];
                        [beginDate addObject:[dicc valueForKey:@"beginDate"]];
                        [endDate addObject:[dicc valueForKey:@"endDate"]];
                        [imageUrlFull addObject:[dicc valueForKey:@"imageUrlFull"]];
                        [useLimitAmt addObject:[dicc valueForKey:@"useLimitAmt"]];
                        
                    }
                    
                    [_table reloadData];
                    
                }
                
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                    
                    //                   NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //                  [Global showTextHud:requestResultStr view:self.view];
                    
                    
                    TheLoginViewController *detailViewController = [[TheLoginViewController alloc] init];
                    [self.navigationController pushViewController:detailViewController animated:YES];
                }
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    
    
    
    
    
    
}





//上拉刷新
- (void)addFooter
{
    
    
    
    MJRefreshFooterView* footer = [MJRefreshFooterView footer];
    footer.scrollView = _table;
    footer.beginRefreshingBlock = ^(MJRefreshBaseView* refreshView)
    {
        
        
        
        [self performSelector:@selector(doneWithView:) withObject:refreshView afterDelay:3.0f];
        NSLog(@"%@--->正在刷新", refreshView.class);
    };
    
}
- (void)doneWithView:(MJRefreshBaseView *)refreshView
{
    [_table reloadData];
    [refreshView endRefreshing];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [couponId count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    CouponListUITableViewCell* cell = (CouponListUITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"CouponListUITableViewCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
    
      cell.selectionStyle =UITableViewCellSelectionStyleNone;
    
    
    
    
    
    
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        NSLog(@"ipad");
    
        UIView *ditu=[[UIView alloc]initWithFrame:CGRectMake(10, 10, (ScreenWidth-20)/3, 120)];
        ditu.backgroundColor=[UIColor colorWithRed:109/255.0 green:168/255.0 blue:33/255.0 alpha:1.0];
        [cell.contentView addSubview:ditu];
        
        UIView *ditu1=[[UIView alloc]initWithFrame:CGRectMake(ditu.right, 10, ScreenWidth-(ScreenWidth-20)/3-20, 120)];
        ditu1.backgroundColor=luseColor;
        [cell.contentView addSubview:ditu1];
        
        NSString*GoldPrice=[NSString stringWithFormat:@"%@",[price objectAtIndex:indexPath.row]];
        UILabel*GoldPricelabel=[[UILabel alloc]initWithFrame:CGRectMake(10, 10, (ScreenWidth-20)/3, 120)];
        GoldPricelabel.text=GoldPrice;
        GoldPricelabel.font=[UIFont boldSystemFontOfSize:42];
        GoldPricelabel.textColor=[UIColor whiteColor];
        GoldPricelabel.textAlignment=NSTextAlignmentCenter;
        [cell.contentView addSubview:GoldPricelabel];
        
        UILabel*shuliang=[[UILabel alloc]initWithFrame:CGRectMake(10, 105, (ScreenWidth-20)/3, 12)];
        shuliang.text=[NSString stringWithFormat:@"发放数量 %@",[NSString stringWithFormat:@"%@",[qty objectAtIndex:indexPath.row]]];
        shuliang.font=[UIFont boldSystemFontOfSize:9];
        shuliang.textColor=[UIColor whiteColor];
        shuliang.alpha=0.5;
        shuliang.textAlignment=NSTextAlignmentCenter;
        [cell.contentView addSubview:shuliang];

        UIImageView*dian=[[UIImageView alloc]initWithFrame:CGRectMake(ditu.right-3, 10, 6, 120)];
        dian.image=[UIImage imageNamed:@"youhuiquanxuxian"];
        [cell.contentView addSubview:dian];

    
    }
    else
    {
        NSLog(@"iphone or ipod");
    
        UIView *ditu=[[UIView alloc]initWithFrame:CGRectMake(10, 10, 120, 120)];
        ditu.backgroundColor=[UIColor colorWithRed:109/255.0 green:168/255.0 blue:33/255.0 alpha:1.0];
        [cell.contentView addSubview:ditu];
        
        UIView *ditu1=[[UIView alloc]initWithFrame:CGRectMake(ditu.right, 10, ScreenWidth-140, 120)];
        ditu1.backgroundColor=luseColor;
        [cell.contentView addSubview:ditu1];
        
        NSString*GoldPrice=[NSString stringWithFormat:@"%@",[price objectAtIndex:indexPath.row]];
        UILabel*GoldPricelabel=[[UILabel alloc]initWithFrame:CGRectMake(10, 10, 120, 120)];
        GoldPricelabel.text=GoldPrice;
        GoldPricelabel.font=[UIFont boldSystemFontOfSize:42];
        GoldPricelabel.textColor=[UIColor whiteColor];
        GoldPricelabel.textAlignment=NSTextAlignmentCenter;
        [cell.contentView addSubview:GoldPricelabel];
        
        UILabel*shuliang=[[UILabel alloc]initWithFrame:CGRectMake(10, 105, 120, 12)];
        shuliang.text=[NSString stringWithFormat:@"发放数量 %@",[NSString stringWithFormat:@"%@",[qty objectAtIndex:indexPath.row]]];
        shuliang.font=[UIFont boldSystemFontOfSize:9];
        shuliang.textColor=[UIColor whiteColor];
        shuliang.alpha=0.5;
        shuliang.textAlignment=NSTextAlignmentCenter;
        [cell.contentView addSubview:shuliang];

        UIImageView*dian=[[UIImageView alloc]initWithFrame:CGRectMake(127, 10, 6, 120)];
        dian.image=[UIImage imageNamed:@"youhuiquanxuxian"];
        [cell.contentView addSubview:dian];

    }
    
    
    
    
    

    
    
    
    UILabel*titlelabel=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-200, 10+43, 150, 16)];
    titlelabel.text=[NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",[title objectAtIndex:indexPath.row]]];
    titlelabel.font=[UIFont boldSystemFontOfSize:16];
    titlelabel.textColor=[UIColor whiteColor];
    titlelabel.textAlignment=NSTextAlignmentRight;
    [cell.contentView addSubview:titlelabel];

    UILabel*contenlabel=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-220, 10+43+16+6, 170, 16)];
    contenlabel.text=[NSString stringWithFormat:@"用券的最低金额 ¥ %@",[useLimitAmt objectAtIndex:indexPath.row]];
    contenlabel.font=[UIFont boldSystemFontOfSize:14];
    contenlabel.textColor=[UIColor whiteColor];
    contenlabel.alpha=0.8;
    contenlabel.textAlignment=NSTextAlignmentRight;
    [cell.contentView addSubview:contenlabel];
    NSRange range={0,10};
    NSString* string =[[NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",[beginDate objectAtIndex:indexPath.row]]] substringWithRange:range];
    NSRange range1={0,10};
    NSString* string1 =[[NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",[endDate objectAtIndex:indexPath.row]]] substringWithRange:range1];
    UILabel*timelabel=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-220, 105, 190, 12)];
    timelabel.text=[NSString stringWithFormat:@"有效期 %@~%@",string,string1];
    timelabel.font=[UIFont boldSystemFontOfSize:9];
    timelabel.textColor=[UIColor whiteColor];
    timelabel.alpha=0.5;
    timelabel.textAlignment=NSTextAlignmentRight;
    [cell.contentView addSubview:timelabel];

    UIButton*fenxiangyouhuiquan=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-70, 10, 60, 60)];
    [fenxiangyouhuiquan setBackgroundImage:[UIImage imageNamed: @"fenxiang-youhuiquan"] forState:UIControlStateNormal];
//   fenxiang-youhuiquan
    fenxiangyouhuiquan.tag=indexPath.row;
    [fenxiangyouhuiquan addTarget:self action:@selector(fenxiangss:) forControlEvents:UIControlEventTouchUpInside];
    [cell.contentView addSubview:fenxiangyouhuiquan];
    
    
    
    
    
    
    
    
    
    
    
    
    return cell;
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return  130;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
//    commdity.actTypeCode=couponId[indexPath.row];
//    
//    BusinessCouponDetailViewController*vc1=[[BusinessCouponDetailViewController alloc] init];
//    
//    [self.navigationController pushViewController:vc1 animated:YES];
}
-(void)closeKeyBoad
{
    [fengxiangview removeFromSuperview];
    [fengxiangScroll removeFromSuperview];
    [quxiao removeFromSuperview];
    [self.window makeKeyWindow];
    self.window.hidden=YES;
}
-(void)fenxiangss:(UIButton*)sender{
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:@"coupon" forKey:@"contentType"];
    [param setValue:couponId[sender.tag] forKey:@"contentId"];
    [param setValue:@"wx_single" forKey:@"shareTarget"];
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    NSLog(@"====%@",param);
    
    [HttpRequest requestData:@"Company/getShareUrl" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                self. shuoming=[severDataDict.dataDict objectForKey:@"shareDescription"];
                
                self. shareUrl=[severDataDict.dataDict objectForKey:@"shareUrl"];
                self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
                fengxiangview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
                fengxiangview.backgroundColor=[UIColor blackColor];
                fengxiangview.alpha=0.5;
                [self.window addSubview:fengxiangview];
                [self.window makeKeyAndVisible];
                
                fengxiangScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,ScreenHeight-240, ScreenWidth,200)];
                fengxiangScroll.delegate = self;
                fengxiangScroll.userInteractionEnabled = YES;
                fengxiangScroll.scrollEnabled = YES;
                fengxiangScroll.showsVerticalScrollIndicator = FALSE;
                fengxiangScroll.showsHorizontalScrollIndicator = FALSE;
                fengxiangScroll.backgroundColor=[UIColor whiteColor];
                [self .window addSubview:fengxiangScroll];
                
                // 手势
                UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
                singleFingerOne.numberOfTouchesRequired = 1; //手指数
                singleFingerOne.numberOfTapsRequired = 1; //tap次数
                singleFingerOne.delegate = self;
                [fengxiangview addGestureRecognizer:singleFingerOne];
                
                
                
                
                NSArray*nameBtn=[[NSArray alloc]initWithObjects:@"发送給朋友",@"分享到朋友圈",nil];
                NSArray *arrayimage = @[@"faweixin",@"fenxiangpenyouquan"];
                for (int i = 0; i<2; i++) {
                    UIButton *nameButcenter = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3*i,   80*ScreenHeight/1334+15, ScreenWidth/3, 60)];
                    
                    [fengxiangScroll addSubview:nameButcenter];
                    
                    
                    UIButton *nameBut = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3*i,   nameButcenter.bottom+20, ScreenWidth/3, 14)];
                    [nameBut setTitle: [nameBtn objectAtIndex:i]  forState:UIControlStateNormal];
                    nameBut.tag=201+i;
                    [nameBut setTitleColor:shenhuicolor forState:0];
                    nameBut.titleLabel.font=[UIFont systemFontOfSize:14];
                    [nameBut addTarget:self action:@selector(fengxiang:) forControlEvents:UIControlEventTouchUpInside];
                    [fengxiangScroll addSubview:nameBut];
                    
                    
                    UIButton *wuyebuttonimage = [UIButton buttonWithType:UIButtonTypeCustom];
                    wuyebuttonimage.frame = CGRectMake(ScreenWidth/3*i,  10, 60, 60);
                    
                    wuyebuttonimage.tag = 201+i;
                    wuyebuttonimage.center=nameButcenter.center;
                    [wuyebuttonimage setImage:[UIImage imageNamed: [arrayimage objectAtIndex:i]] forState:UIControlStateNormal];
                    [wuyebuttonimage addTarget:self action:@selector(fengxiang:) forControlEvents:UIControlEventTouchUpInside];
                    [fengxiangScroll addSubview:wuyebuttonimage];
                    
                    
                }
                
                
                quxiao = [[UIButton alloc] initWithFrame:CGRectMake(0,ScreenHeight-45,  ScreenWidth, 45)];
                [quxiao setTitle:@"取消" forState:UIControlStateNormal];
                quxiao.titleLabel.font=[UIFont systemFontOfSize:16];
                quxiao.backgroundColor=[UIColor whiteColor];
                [quxiao setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                [quxiao addTarget:self action:@selector(closeKeyBoad) forControlEvents:UIControlEventTouchUpInside];
                [self .window addSubview:quxiao];
                UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, ScreenWidth-30, 0.35)];
                line.backgroundColor=qianhuicolor;
                [quxiao addSubview:line];
                
                
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    
    
}






-(void)fengxiang:(UIButton*)sender{
    [fengxiangview removeFromSuperview];
    [fengxiangScroll removeFromSuperview];
    [quxiao removeFromSuperview];
    [self.window makeKeyWindow];
    self.window.hidden=YES;
    NSURL *url = [NSURL URLWithString:[commdity.Dict objectForKey:@"imageUrlFull"]];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *image1 = [[UIImage alloc] initWithData:data];
    if (sender.tag==201) {
        if (![[commdity.Dict objectForKey:@"detail"]isEqualToString:@""]) {
            self.shuoming=[commdity.Dict objectForKey:@"detail"];
        }
        [UMSocialData defaultData].extConfig.wechatSessionData.title =[commdity.Dict objectForKey:@"title"];
        UMSocialUrlResource *urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeDefault url:self.shareUrl];
        
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatSession].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
        [UMSocialData defaultData].extConfig.wechatSessionData.url = self.shareUrl;
        [[UMSocialDataService defaultDataService]postSNSWithTypes:@[UMShareToWechatSession] content:self.shuoming image:image1 location:nil urlResource:urlResource presentedController:self completion:^(UMSocialResponseEntity *response){
            
            if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
            }
            
        }];
        
        
        
        
        
        
    }
    
    if (sender.tag==202) {
        
        
        UMSocialUrlResource *urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeDefault url:self.shareUrl];
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatTimeline].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
        [UMSocialData defaultData].extConfig.wechatTimelineData.url = self.shareUrl;
        [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatTimeline] content:[NSString stringWithFormat:@"%@",  [commdity.Dict objectForKey:@"title"]] image:image1 location:nil urlResource:urlResource presentedController:self completion:^(UMSocialResponseEntity *response){
            if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
            }
        }];
        
        
        
        
    }
    
}


- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}


@end
